package observer;

import observer.observer.CurrentConditions;
import observer.observer.ForecastConditions;
import observer.subject.WeatherDataSt;

/**
 * @author: zhouyang
 * @descrpition: 观察者模式 是设计模式中一对多场景
 * 用Subject 管理多观察者
 * 观察者通过在Subject里注册 完成消息更新的通知
 * @time: 2019-04-28 20:21
 */
public class Main {
    public static void main(String[] args) {
        CurrentConditions currentConditions;
        ForecastConditions forecastConditions;

        WeatherDataSt weatherDataSt;

        weatherDataSt = new WeatherDataSt();

        currentConditions = new CurrentConditions();
        forecastConditions = new ForecastConditions();

        weatherDataSt.registerObserver(currentConditions);
        weatherDataSt.registerObserver(forecastConditions);


        weatherDataSt.setData(30, 150, 40);


        weatherDataSt.removeObserver(currentConditions);
        weatherDataSt.setData(40, 250, 50);
    }
}
